{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cdd3659e",
   "metadata": {},
   "source": [
    "* 时间：2022-10-25/week10\n",
    "* 记录人：爹"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24f91bcb",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "\n",
    ">1. while循环\n",
    ">>1. 指定次数，while True 可以实现for循环指定次数，增加count计数器即\n",
    ">>2. while True 一般与用户输入 一起使用，让用户可以重复输入，知道莫些\n",
    ">2. 购物车实践（平时作业）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92bf99ce",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    ">1. 元组\n",
    ">2. 集合\n",
    ">3. 字典"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b305e601",
   "metadata": {},
   "source": [
    "# 1.元组（tuple）\n",
    "\n",
    ">1. 元组的基本内容（形态、定义）\n",
    ">2. 元组的一般方法\n",
    ">>1. 有序性（indexing,sliceing)\n",
    ">>2. <font color=\"red>**不可变性**</font>,元组没有增、删、改\n",
    ">3.元组的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4727b722",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1800001, 1800002, 1800003) <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "网三_学号 = (1800001,1800002,1800003)\n",
    "print(网三_学号,type(网三_学号))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fdff51c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1900001, 1900002, 1900003) <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "网二_学号 = 1900001,1900002,1900003\n",
    "print(网二_学号,type(网二_学号))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5ef2b89e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1900001"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_学号[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c1140002",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1900002, 1900003)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_学号[1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3109eaf7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=10, tm_mday=25, tm_hour=15, tm_min=6, tm_sec=58, tm_wday=1, tm_yday=298, tm_isdst=0)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 元组的实际案例\n",
    "import time\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "64b6555d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([1, 2, 3, 4], [3, 4, 5, 6]) <class 'tuple'> 1638593069184\n",
      "[1, 2, 3, 4] 1638595074880\n"
     ]
    }
   ],
   "source": [
    "tuple_test = ([1,2,3,4],[3,4,5,6])\n",
    "print(tuple_test,type(tuple_test),id(tuple_test))\n",
    "print(tuple_test[0],id(tuple_test[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "269fe92b",
   "metadata": {},
   "outputs": [],
   "source": [
    "tuple_test[0].append(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "c632cecd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([1, 2, 3, 4, 100], [3, 4, 5, 6]) <class 'tuple'> 1638593069184\n",
      "[1, 2, 3, 4, 100] 1638595074880\n"
     ]
    }
   ],
   "source": [
    "print(tuple_test,type(tuple_test),id(tuple_test))\n",
    "print(tuple_test[0],id(tuple_test[0]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "813ffefa",
   "metadata": {},
   "outputs": [],
   "source": [
    "#一般情况下，元组里面存放的是  常量(不可变)，何为常量：数字，字符串\n",
    "#不存放变量 如：列表，字典"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "50e24232",
   "metadata": {},
   "source": [
    "## 2.集合（sets)\n",
    ">1. 集合的集合概念\n",
    ">>1. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "23191949",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['apple', 'orange', 'pear', 'banana']\n"
     ]
    }
   ],
   "source": [
    "basket_lists = ['apple','orange','pear','banana']\n",
    "print(basket_lists)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "cd610357",
   "metadata": {},
   "outputs": [],
   "source": [
    "舞蹈社 = {1801,1802,1803,1809,1811,1812}\n",
    "电竞社 = {1808,1822,1802,1801,1888,1899}"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05257acd",
   "metadata": {},
   "source": [
    "* 集合的与运算，交集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "839868d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1801, 1802}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社 & 电竞社"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8a745e7f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1801, 1802}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社.intersection(电竞社)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "402dd0d0",
   "metadata": {},
   "source": [
    "* 集合的与运算，并集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "ca05eaac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1801, 1802, 1803, 1808, 1809, 1811, 1812, 1822, 1888, 1899}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社 | 电竞社"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "6db3843e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(舞蹈社 | 电竞社)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "67500013",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1801, 1802, 1803, 1808, 1809, 1811, 1812, 1822, 1888, 1899}"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社.union(电竞社)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09470c18",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
